/* Create a template-set of the org.parademo.model */
/* This is the basic set of templates that will be used by Parademo application */

;List existing templates-facts
(facts)

(printout t "Creating the Templates model for Parademo:" crlf)

;Basic Template - 'Entity'
(
    deftemplate Entity
		"Basic model template"
		(slot id (type LONG))
)

;Template 'Address' - the address of each user.
(
    deftemplate Address extends Entity
		"Address of each user in the system"
		(slot streetName (type STRING))
		(slot houseNumber (type STRING))
		(slot zipCode (type STRING))
		(slot city (type STRING))
    	(slot countryId (type LONG)) ;How to access this from another table as FK?
)

;Template 'Community' - the template to represent a community
(
    deftemplate Community extends Entity
		"To represent a community"
		(slot name (type STRING))
    	(slot regionId (type LONG))
    	(slot parentId (type LONG))
)

;Template 'Proposal' - the template to represent a user proposal
(
    deftemplate Proposal extends Entity
		"To represent a user proposal"
		(slot title (type STRING))
        (slot description (type STRING))
        (slot internal (type STRING))
    	(slot votingStartDate (type LONG))
    	(slot votingEndDate (type LONG))
	    (slot topicId (type LONG))
	    (slot userId (type LONG))
    	(slot proposalStatusId (type LONG))
)

;Template 'ProposalStatus' - the template to represent statuses of a Proposal
(
    deftemplate ProposalStatus extends Entity
		"To represent the possible states of a proposal"
		(slot title (type STRING))
    	(slot code (type LONG)) ;should this be a STRING?
)

;Template 'Region' - the geographical region of the community
(
    deftemplate Region extends Entity
		"To represent a region, i.e, the geo location of a community"
    	(slot latitude (type LONG))
    	(slot longitude (type LONG))
)

;Template 'TokenCredit' - Token credit left for a user
(
    deftemplate TokenCredit extends Entity
		"The Token credit left for a user, based on topic"
    	(slot tokenCredit (type INTEGER))
    	(slot topicId (type LONG))
    	(slot userId (type LONG))
)

;Template 'Topic' - The available topics or category to create proposals in
(
    deftemplate Topic extends Entity
		"The available topics or category to create proposals in"
		(slot title (type STRING))
        (slot description (type STRING))
)

;Template 'User' - the template to represent a user
(
    deftemplate User extends Entity
		"A User of Parademo"
		(slot password (type STRING))
        (slot firstName (type STRING))
    	(slot lastName (type STRING))
    	(slot joinDate (type LONG))
    	(slot birthDate (type LONG))
		(slot addressId (type LONG))
)

;Template 'Vote' - the vote cast by a user on a proposal
(
    deftemplate Vote extends Entity
		"A vote"
    	(slot tokens (type INTEGER))
    	(slot proposalId (type LONG))
    	(slot userId (type LONG))
)
